package ba.unsa.etf.pikks.tests;

import static org.junit.Assert.*;

import org.junit.Test;

import ba.unsa.etf.pikks.LoC.LOC;
import ba.unsa.etf.pikks.mccabe.McCabe;

import java.io.File;
import java.util.*;

public class UnitTest {

    @Test
    public void testMcCabe(){
    	McCabe aMcCabe= new McCabe();
		HashMap<String,Integer> mcCabeComplexity = new HashMap<String, Integer>();
		String nameOfMethod = "Class";
		
		try {
			mcCabeComplexity = aMcCabe.getMcCabe( new File("Primjeri/tests.java"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		assertTrue ( mcCabeComplexity.get(nameOfMethod) != null );
    	assertEquals( (int)4, (int)mcCabeComplexity.get(nameOfMethod));
    }
    
    @Test 
    public void testLocCounter_1() {
    	Map<String, Integer> locCounterResultMap = new HashMap<String, Integer>();
    	String nameOfMethod = "Class";
    	
    	try {
    		LOC locCounter = new LOC();
    		locCounterResultMap = locCounter.LocCounterManager( new File("Primjeri/tests.java") );
    	} catch (Exception e) {
    		System.out.println(e);
    	}
    	
    	assertTrue( locCounterResultMap.get(nameOfMethod) != null );
    	assertEquals( (int)15, (int)locCounterResultMap.get(nameOfMethod) );
    }
    

    @Test 
    public void testLocCounter_2() {
    	Map<String, Integer> locCounterResultMap = new HashMap<String, Integer>();
    	String nameOfMethod = "public void b(String d)";
    	
    	try {
    		LOC locCounter = new LOC();
    		locCounterResultMap = locCounter.LocCounterManager( new File("Primjeri/tests.java") );
    	} catch (Exception e) {
    		System.out.println(e);
    	}
    	
    	assertTrue( locCounterResultMap.get(nameOfMethod) != null );
    	assertEquals( (int)3, (int)locCounterResultMap.get(nameOfMethod) );
    }
    
}
